// sum_arr1.c -- sums the elements of an array
// use %u or %lu if %zd doesn't work

#include <stdio.h>
#define SIZE 10

int sum(int * start, int * end);

int main(void)
{
    int nums[SIZE] = {20,10,5,39,4,16,19,26,31,20};
    long answer;
    
    answer = sum(nums, nums + SIZE);
    printf("The total number of nums is %ld.\n", answer);
    printf("The size of nums is %zd bytes.\n", sizeof nums);
    
    return 0;
}

int sum(int *start, int * end)     // how big an array?
{
    int i;
    int total = 0;
    
    while (start < end)
    {
      total += *start;
      start++;
    }
    
    return total;
}
